﻿using IntelligentAgriculture.Contracts.Interface;
using IntelligentAgriculture.WebAPI.Application.Command.BreedingInfoCommand;
using IntelligentAgriculture.WebAPI.Application.Command.StartCommand;
using MediatR;

namespace IntelligentAgriculture.WebAPI.Application.CommandHandler.BreedingInfoCommandHandler
{   
    /// <summary>
    /// 种母配种添加CommandHandler
    /// </summary>
    public class AddBreedingInfoCommandHandler : IRequestHandler<AddBreedingInfoCommand, Results<int>>
    {

        private readonly IBreedingInfoService _service;
        public AddBreedingInfoCommandHandler(IBreedingInfoService service)
        {
            _service = service;
        }

        public async Task<Results<int>> Handle(AddBreedingInfoCommand request, CancellationToken cancellationToken)
        {
            var list = await _service.AddBreedinginfoAsync(request.Breedinginfos);
            // 返回结果
            return Results<int>.DataResult(list);
        }
    }
}
